import 'package:aqua_plunge/constants/colors.dart';
import 'package:flutter/material.dart';

import '../util/MedalType.dart';

class MedalsDialog extends StatelessWidget {
  final MedalType type;

  const MedalsDialog({super.key, required this.type});

  @override
  Widget build(BuildContext context) {
    String selectmedal = '';
    String selecttag = '';
    String describe = '';

    List<String> medalPaths = [
      'images/icon_medal_level1.png',
      'images/icon_medal_level2.png',
      'images/icon_medal_level3.png',
      'images/icon_medal_level4.png',
      'images/icon_super_level1.png',
      'images/icon_super_level2.png',
      'images/icon_super_level3.png',
      'images/icon_super_level4.png'
    ];

    List<String> congratulations = [
      'images/icon_congratulation_level1.png',
      'images/icon_congratulation_level2.png',
      'images/icon_congratulation_level3.png',
      'images/icon_congratulation_level4.png'
    ];

    switch (type) {

      case MedalType.level2:
        {
          selectmedal = medalPaths[1];
          selecttag = congratulations[1];
          describe = "You've earned a new medals. Check it out now!";
        }
        break;
      case MedalType.level3:
        {
          selectmedal = medalPaths[2];
          selecttag = congratulations[2];
          describe = "You've earned a new medals. Check it out now!";
        }
        break;
      case MedalType.level4:
        {
          selectmedal = medalPaths[3];
          selecttag = congratulations[3];
          describe = "You've earned a new medals. Check it out now!";
        }
        break;


      case MedalType.upgrade1:
        {
          selectmedal = medalPaths[4];
          selecttag = congratulations[0];
          describe = "You've earned a new medals. Check it out now!";
        }
        break;
      case MedalType.upgrade2:
        {
          selectmedal = medalPaths[5];
          selecttag = congratulations[1];
          describe = "You've earned a new medals. Check it out now!";
        }
        break;
      case MedalType.upgrade3:
        {
          selectmedal = medalPaths[6];
          selecttag = congratulations[2];
          describe = "You've earned a new medals. Check it out now!";
        }
        break;
      case MedalType.upgrade4:
        {
          selectmedal = medalPaths[7];
          selecttag = congratulations[3];
          describe = "You've earned a new medals. Check it out now!";
        }
        break;

      case MedalType.level1:
      default:
        {
          selectmedal = medalPaths[0];
          selecttag = congratulations[0];
          describe = "This is a beginner's medal for you, go clock in for a more advanced medal!";
        }
        break;
    }

    return Dialog(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(16.0),
      ), // 设置圆角
      elevation: 0, // 阴影效果
      backgroundColor: Colors.transparent, // 背景颜色透明
      child: Stack(
        children: [
          Container(
            // 使用Container包裹内容
            width: 292,
            height: 366,
            decoration: BoxDecoration(
              image: const DecorationImage(
                  image: AssetImage('images/icon_medal_dialog_front.png'),
                  fit: BoxFit.fill),
              borderRadius: BorderRadius.circular(12.0), // 再次设置圆角
            ),
            child: Stack(
              alignment: Alignment.topCenter,
              children: [
                Container(
                  width: 231,
                  height: 253,
                  margin: const EdgeInsets.only(top: 42),
                  decoration: const BoxDecoration(
                      image: DecorationImage(
                          image:
                              AssetImage('images/img_medal_content_bg.png'))),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Image.asset(
                        selecttag,
                        width: 149,
                        height: 24,
                      ),
                      const SizedBox(height: 10),
                      Image.asset(
                        selectmedal,
                        width: 130,
                        height: 130,
                      ),
                      const SizedBox(height: 35),
                      Expanded(
                        child: Text(
                          describe,
                          style:const  TextStyle(fontSize: 12, color: Colors.black),
                          maxLines: 2,
                          overflow: TextOverflow.ellipsis,
                          textAlign: TextAlign.center,
                        ),
                      )
                    ],
                  ),
                ),
                Positioned(
                    bottom: 23,
                    child: InkWell(
                      child: Container(
                        width: 218,
                        height: 37,
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(18),
                            gradient: const LinearGradient(
                                colors: [Color(0xFFFEFEFE), Color(0xFFD7BEFF)],
                                begin: Alignment.topCenter,
                                end: Alignment.bottomCenter)),
                        child: const Center(
                            child: Text(
                          'OK',
                          style: TextStyle(
                              color: AppColors.primaryColor,
                              fontWeight: FontWeight.w900,
                              fontSize: 18),
                        )),
                      ),
                      onTap: () {
                        Navigator.pop(context);
                      },
                    )),
              ],
            ),
          ),
          Image.asset(
            'images/icon_medal_dialog_bg.png',
            height: 250,
            width: double.infinity,
            fit: BoxFit.fill,
          )
        ],
      ),
    );
  }
}


